<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/thesame.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/footer.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/rightCon.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/popCss.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/layer/theme/default/layer.css}" media="all">
</head>

<body class="layui-layout-body layui-layout-body-scroll">
<div class="layui-body layui-body-bot">
    <!-- 内容主体区域 -->
    <div class="add-title"><span class="mr10px cursor return"><img th:src="@{/static/img/icon_return.png}"></span><span>新建人员信息</span></div>
    <div class="scroll-box scroll-box-top scroll-box-bot bgWhite box-shadows border-radius1">
        <div class="scroll-box-padding">
            <div class="scroll-box-con">
                <div class="add-title-border">人员信息</div>
                <article class="form-user-article">
                    <div>
                        <!-- disabled="" -->
                        <div class="form-style form-box form-user-new-mess">
                            <div>
                                <div class="form-title">
                                    <label><em class="red">*</em>部门：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <select class="form-select-img" id="deptName">

                                        </select>
                                    </p>
                                </div>
                            </div>
                            <div>
                                <div class="form-title">
                                    <label><em class="red">*</em>类别：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <select class="form-select-img" id="gou">
                                            <option value="">请选择</option>
                                            <option value="1">员工</option>
                                            <option value="2">访客</option>
                                        </select>
                                    </p>
                                </div>
                            </div>
                            <div>
                                <div class="form-title">
                                    <label><em class="red">*</em>姓名：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <input type="text" id="userName" placeholder="请输入" maxlength="30">
                                    </p>
                                </div>
                            </div>
                            <div>
                                <div class="form-title">
                                    <label><em class="red">*</em>性别：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <select class="form-select-img" id="userSex">
                                            <option value="">请选择</option>
                                            <option value="1">男</option>
                                            <option value="2">女</option>
                                        </select>
                                    </p>
                                </div>
                            </div>
                            <div>
                                <div class="form-title">
                                    <label><em class="red">*</em>手机号码：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <input type="number" id="mobile" oninput="if(value.length>11)value=value.slice(0,11)" placeholder="请输入">
                                    </p>
                                </div>
                            </div>
                            <div id="xiaoshi">
                                <div class="form-title">
                                    <label>卡号：</label>
                                </div>
                                <div class="form-content">
                                    <p>
                                        <input maxlength="30" type="text" id="cardId" placeholder="请输入">
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="xiaoshi2">
                        <dl>
                            <input type="file" class="hidden file"/>
                            <dt class="relative filejs"><img id="showImg" th:src="@{/static/img/moren.png}" class="block">
                                <span class="block white lh30px border-bot-radius4 cursor">上传照片</span></dt>
                            <span id="status"></span>
                            <dd class="gray f12px">支持jpg/jpeg/png格式不大于2M</dd>
                            <!--                            <input type="checkbox" id="asdf">-->
                        </dl>
                    </div>
                </article>
                <div>
                    <div class="add-title-border mt20px">门禁设备</div>
                    <div class="mb20px lh32px overflow table-btn-img">
                        <p class="left">
                            <span class="white border-radius4 bgBlue-linear inline-block pl15px pr15px cursor" id="addDev"><img th:src="@{/static/img/icon_add.png}">添加</span>
                        </p>
                    </div>
                    <div class="border1px border-box border-radius4" id="contentGou">
                        <table class="layui-table layui-table-header form-style layui-form">
                            <thead>
                            <tr>
                                <th>门禁设备</th>
                                <th>起始时间</th>
                                <th>结束时间</th>
                                <th>全天</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="yuangong">
                            <!-- <tr>
                                 <td>总部大门人脸</td>
                                 <td><input type="text" placeholder="-" disabled="disabled" class="form-input-time1"></td>
                                 <td><input type="text" placeholder="-" disabled="disabled" class="form-input-time1"></td>
                                 <td><input type="checkbox" checked="checked" name="111" lay-skin="primary"></td>
                                 <td><span class="blue">删除</span></td>
                             </tr>
                             <tr>
                                 <td>研发中心大门人脸</td>
                                 <td><input type="text" placeholder="-" class="form-input-time2 test-item"></td>
                                 <td><input type="text" placeholder="-" class="form-input-time2 test-item"></td>
                                 <td><input type="checkbox" name="" lay-skin="primary"></td>
                                 <td><span class="blue">删除</span></td>
                             </tr>
                             <tr>
                                 <td>研发中心大门人脸</td>
                                 <td><input type="text" placeholder="-" class="form-input-time2"></td>
                                 <td><input type="text" placeholder="-" class="form-input-time2"></td>
                                 <td><input type="checkbox" name="" lay-skin="primary"></td>
                                 <td><span class="blue">删除</span></td>
                             </tr>-->
                            </tbody>
                            <tbody id="qing">
                            <tr>
                                <td colspan="5" style="border: 0;">请添加门禁设备</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="border1px border-box border-radius4" id="contentGou2" style="display: none">
                        <table class="layui-table layui-table-header form-style layui-form">
                            <thead>
                            <tr>
                                <th>门禁设备</th>
                                <th>访客码</th>
                                <th>来访日期</th>
                                <th>开始时间</th>
                                <th>结束时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="fangke">
                            <!-- <tr>
                                 <td>研发中心大门人脸</td>
                                 <td>1234</td>
                                 <td><input type="text" placeholder="2020-04-16" class="form-input-time2 test-ytd"></td>
                                 <td><input type="text" placeholder="-" class="form-input-time2 test-start"></td>
                                 <td><input type="text" placeholder="-" class="form-input-time2 test-end"></td>
                                 <td><span class="blue">删除</span></td>
                             </tr>-->
                            <tbody id="qing2">
                            <tr>
                                <td colspan="5" style="border: 0;">请添加门禁设备</td>
                            </tr>
                            </tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-footer layui-footer-one">
    <div class="btn-con textCenter">
        <span class="btn-cancel return">取&nbsp;消</span>
        <span class="btn-submit" id="sub">提&nbsp;交</span>
    </div>
</div>
<!--弹层-->
<div id="pop-con" style="display: none">
    <div class="pop-up">
        <!-- 修改密码 -->
        <div class="form-style">
            <div class="pop-title relative overflow mb15px">
                <span class="ml15px f16px">添加门禁设备</span>
                <p class="right"><img src="../static/img/icon_close.png" class="block pop-close">
                <p>
            </div>
            <div class="mt30px mb30px">
                <div class="use-con use-con-pop layui-form">
                    <div class="use-three border-radius4 border1px-ddd">
                        <article class="use-list use-three-list layui-form">
                            <nav>
                                <div id="cont">

                                </div>
                            </nav>
                        </article>
                    </div>
                </div>
            </div>
            <div class="btn-con textCenter">
                <span class="btn-submit pop-close" onclick="laji()">确&nbsp;定</span>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/static/js/jquery-3.1.1.min.js}"></script>
<script th:src="@{/static/js/selectColor.js}"></script>
<script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/static/layer/layer.js}" charset="utf-8"></script>
<script th:inline="javascript">

    var userNo = [[${userNo}]]

    $(function () {


        $(".return").on('click', function () {
            window.history.back();
        })

        //加载部门
        loadDept()

        //加载设备
        // getDevs()

        $("#gou").on('change', htmlChange)

        $("#deptName").on('change', function () {
            loadDev();
            //    将选择的设备清除
            $("#yuangong").empty();
            $("#fangke").empty();
        })

        $("#addDev").on('click', layerOpen)

        $(".filejs").click(function () {
            $(".file").click();
        });

        $(".file").on("change", function () {
            var file = $(".file").val();
            if (!file.match(/.jpg|.png|.jpeg/i)) {　　//判断上传文件格式
                layer.open({
                    content: '上传的图片格式不正确，请重新选择'
                    , skin: 'msg'
                    //,time: 2 //2秒后自动关闭
                });
                return;
            }
            var fileObj = this.files[0];
            if (fileObj.size / (1024 * 1024) > 2) {
                layer.open({
                    content: '上传的图片大小不能超过2M，请重新选择'
                    , skin: 'msg'
                    //,time: 2 //2秒后自动关闭
                });
                return;
            }
            var data = new FormData();
            data.append("file", fileObj);
            $.ajax({
                url: "../upload/uploadImage",
                type: "post",
                data: data, //JSON.stringify({"file": file}),
                dataType: "json",
                // contentType: "application/json",
                async: false,
                processData: false,   //用FormData传fd时需有这两项     必要
                contentType: false,
                success: function (data) {
                    if (data.code == 200) {
                        $("#showImg").attr("src", data.imageUrl);
                        isFaceApiIdentify(data.imageUrl);
                    } else {
                        $("#showImg").html(data.msg);
                    }
                }
            });
        });

        //    全选
        layui.use(['form', 'jquery'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            //点击全选, 勾选
            form.on('checkbox(allChoose)', function (data) {
                var child = $("#cont ul input[type='checkbox']");
                child.each(function (index, item) {
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
        });

        //    全选
        layui.use(['form', 'jquery'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            //点击全选, 勾选
            form.on('checkbox(childAllChoose)', function (data) {
                var child = $(this).parent().parent().siblings('ul').find('input');
                child.each(function (index, item) {
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
        });

        //    全选
        layui.use(['form', 'jquery'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            //点击全选, 勾选
            form.on('checkbox(che)', function (data) {
                if (data.elem.checked == false) {
                    // console.log($(this).parent().siblings().find('input'))
                    $(this).parent().siblings().find('input').removeAttr("disabled")
                } else {
                    $(this).parent().siblings().find('input').attr("disabled", "disabled")
                    $(this).parent().siblings().find('input').each(function () {
                        $(this).val("");
                    })
                }
            });
        });

        //初始化
        loadData();

        //初始化设备
        loadDev();


        $("#sub").on('click', saveUser);


    });

    function layerOpen() {
        var dept = $("#deptName").val();
        layui.use(['element', 'form', 'layer'], function () {
            var element = layui.element;
            var form = layui.form;
            var layer = layui.layer;
            if (isNull(dept)) {
                layer.msg("请选择部门")
                return;
            }
            layer.open({
                type: 1
                , title: false //不显示标题栏
                , closeBtn: false
                //新建组织
                , area: ['400px', '']
                , shade: 0.6
                , id: 'payCons' //设定一个id，防止重复弹出
                /*,btn: ['确认支付']*/
                , btnAlign: 'c'
                , moveType: 1 //拖拽模式，0或者1
                , shadeClose: true //设置允许点遮罩关闭
                , content: $("div#pop-con"),
                success: function () {
                    //关闭弹层
                    $(".pop-close").click(function () {
                        layer.closeAll();
                    });
                },

            });
        });
    }

    //左侧菜单栏
    layui.use(['element', 'form', 'laydate'], function () {
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate;
        lay('.test-item').each(function () {
            laydate.render({
                elem: this,
                trigger: 'click',
                /*value: '1989-10-14'*/
                type: 'time'
            });
        });
        var now = new Date();
        lay('.test-item2').each(function () {
            laydate.render({
                elem: this,
                trigger: 'click',
                min: now.toLocaleString()
                /*value: '1989-10-14'*/
            });
        });
    });

    function htmlChange() {
        var type = $(this).val();
        if (type == 1) {
            $("#xiaoshi").css("display", "")
            $("#xiaoshi2").css("display", "")
            $("#contentGou").css("display", "")
            $("#contentGou2").css("display", "none")
        } else if (type == 2) {
            $("#xiaoshi").css("display", "none")
            $("#xiaoshi2").css("display", "none")
            $("#contentGou").css("display", "none")
            $("#contentGou2").css("display", "")
        }
    }

    function loadDev() {

        var dept = $("#deptName").val();
        var data = {deptNo: dept};
        $.ajax({
            url: "../cuser/getDevByDeptNo",
            type: "get",
            data: data,
            async: false,
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    var str = "<p><span class=\"use-arrow cursor\"><img src=\"../static/img/icon_select_right.png\"></span>" +
                        "<span class=\"mr5px\"><input lay-filter=\"allChoose\" type=\"checkbox\" name=\"\" lay-skin=\"primary\" " +
                        "title=" + data.data.deptName + ">" +
                        "</span></p>"
                    if (data.data.data.length > 0) {
                        str += "<ul>"
                        for (var i = 0; i < data.data.data.length; i++) {
                            str += "<li><input id=" + data.data.data[i].id + " type=\"checkbox\" name=\"\" lay-skin=\"primary\" " +
                                "title=" + data.data.data[i].deviceName + "></li>"
                        }
                        str += "</ul>"
                    }
                    $("#cont").html(str);
                }
                layui.use('form', function () {
                    var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
                    form.render();
                });
            }
        })

    }

    function getDevs() {
        $.ajax({
            url: "../cuser/getDeptDevTree",
            type: "get",
            async: false,
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    var str = "";
                    if (data.data.userType == 1 && data.data.data.length > 0) {
                        str += "<p><span class=\"use-arrow cursor\"><img src=\"../static/img/icon_select_right.png\"></span>" +
                            "<span class=\"mr5px\"><input lay-filter=\"allChoose\" type=\"checkbox\" name=\"\" lay-skin=\"primary\" " +
                            "title=" + data.data.orgName + ">" +
                            "</span></p>"
                        for (var i = 0; i < data.data.data.length; i++) {
                            str += "<ul><p><span class=\"use-arrow cursor\"><img src=\"../static/img/icon_select_right.png\"></span>" +
                                "<span class=\"mr5px\"><input lay-filter=\"childAllChoose\" type=\"checkbox\" value=" + data.data.data.id + " " +
                                "name=\"\" lay-skin=\"primary\" title=" + data.data.data[i].deptName + ">" +
                                "</span></p>"
                            if (data.data.data[i].list.length > 0) {
                                str += "<ul>"
                                for (var j = 0; j < data.data.data[i].list.length; j++) {
                                    str += "<li><input id=" + data.data.data[i].list[j].id + " type=\"checkbox\" name=\"\" lay-skin=\"primary\" " +
                                        "title=" + data.data.data[i].list[j].deviceName + "></li>"
                                }
                                str += "</ul>"
                            }
                            str += "</ul>"
                        }
                    }
                    $("#cont").html(str);
                }
            }
        })
    }

    function loadDept() {
        $.ajax({
            url: "../userDept/getDeptByUser",
            type: "get",
            async: false,
            dataType: "json",
            success: function (data) {
                var str = "<option value=''>请选择</option>";
                if (data.code == 200) {
                    if (data.data.length > 0) {
                        for (var i = 0; i < data.data.length; i++) {
                            str += "<option value=" + data.data[i].id + ">" + data.data[i].deptName + "</option>"
                        }
                    }
                }
                $("#deptName").html(str);
            }
        })
    }

    // 添加门禁设备
    $(function () {
        $('.use-list p span.use-arrow').click(function () {
            $(this).parent().siblings().slideToggle(300);
            if ($(this).find('img').attr('src') == '../static/img/icon_select_right.png') {
                $(this).find('img').attr('src', '../static/img/icon_select_down.png');
            } else {
                $(this).find('img').attr('src', '../static/img/icon_select_right.png')
            }
        })
    });

    //验证人脸
    function isFaceApiIdentify(imageUrl) {
        var formDate = {
            imageUrl: imageUrl,
        }
        $.ajax({
            url: "../cuser/isFaceApiIdentify",
            type: "post",
            dataType: "json",
            data: formDate,
            async: true,
            success: function (data) {
                $("#status").html(data.msg);
                $("#status").attr("value", data.code);
                if (data.code == 0) {
                    $("#status").css("color", "green")
                } else if (data.code == 99) {
                    $("#status").css("color", "red")
                } else {
                    $("#status").css("color", "red")
                }
            }
        });
    }

    //确定
    function laji() {
        var userType = $("#gou").val();
        var data = new Array();
        var checks = $("#cont ul li input[type=checkbox]:checked").each(function () {
            var object = new Object();
            object.id = $(this).attr("id")
            object.name = $(this).attr("title")
            data.push(object);
        })

        console.log(userType);
        console.log(data);

        //判断用户类别 1.员工 2访客
        if (isNull(userType) || userType == 1 && data.length > 0) {
            var str = "";
            for (var i = 0; i < data.length; i++) {
                str += "<tr><td id=" + data[i].id + ">" + data[i].name + "</td>"
                str += "<td><input type=\"text\" placeholder=\"-\" disabled='disabled'  class=\"form-input-time1 test-item\"></td>" +
                    "<td><input type=\"text\" placeholder=\"-\"  disabled='disabled' class=\"form-input-time1 test-item\"></td>" +
                    "<td><input type=\"checkbox\" checked=\"checked\" name=\"111\" lay-skin=\"primary\"lay-filter='che'></td>" +
                    "<td><span class=\"blue\" onclick='delDev(this)'>删除</span></td></tr>"
            }
            $("#yuangong").html(str);
            $("#qing").css("display", "none")

        } else if (userType == 2 && data.length > 0) {
            var str = "";
            for (var i = 0; i < data.length; i++) {
                str += "<tr><td id=" + data[i].id + ">" + data[i].name + "</td><td>" + getRandom() + "</td>"
                str += "<td><input type=\"text\" placeholder=\"请选择\" class=\"form-input-time2 test-ytd test-item2\"></td>" +
                    "<td><input type=\"text\" placeholder=\"-\" class=\"form-input-time2 test-start test-item\"></td>" +
                    "<td><input type=\"text\" placeholder=\"-\" class=\"form-input-time2 test-end test-item\"></td>" +
                    "<td><span class=\"blue\" onclick='delDev(this)'>删除</span></td></tr>"
            }
            $("#fangke").html(str);
            $("#qing2").css("display", "none")
        }
        layui.use('form', function () {
            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            var element = layui.element;
            var laydate = layui.laydate;
            lay('.test-item').each(function () {
                laydate.render({
                    elem: this,
                    trigger: 'click',
                    /*value: '1989-10-14'*/
                    type: 'time'
                });
            });

            lay('.test-item2').each(function () {
                laydate.render({
                    elem: this,
                    trigger: 'click',
                    /*value: '1989-10-14'*/
                });
            });
            form.render();
        });


    }

    function delDev(e) {
        $(e).parent().parent().remove();
    }

    function isNull(value) {
        return value == null || value === "" || value === undefined;
    }

    //4位随机数
    function getRandom() {
        var charactors = "1234567890";

        var value = '', i;

        for (var j = 1; j <= 4; j++) {
            i = parseInt(10 * Math.random());
            value = value + charactors.charAt(i);
        }

        return value;
    }

    //保存用户
    function saveUser() {
        var datas = new Array();
        var deptId = $("#deptName").val();
        var userType = $("#gou").val();
        var userName = $("#userName").val();
        var userSex = $("#userSex").val();
        var mobile = $("#mobile").val();
        var cardNo = $("#cardId").val();
        var userPhoto = $("#showImg").attr("src");
        var status = $("#status").attr("value");

        if (isNull(deptId)) {
            layer.msg("请选择部门")
            return;
        }

        if (isNull(userType)) {
            layer.msg("请选择类别")
            return;
        }

        if (isNull(userName)) {
            layer.msg("请输入姓名")
            return;
        }

        if (isNull(userSex)) {
            layer.msg("请选择性别")
            return;
        }

        if (isNull(mobile)) {
            layer.msg("请输入手机号")
            return;
        }

        if (!isPhoneNumber(mobile)) {
            layer.msg("手机号格式不正确")
            return;
        }
        if (userType == 1) {
            if (isNull(userPhoto) || userPhoto == '/AccessManage/static/img/moren.png') {
                layer.msg("请上传图片")
                return;
            }
            console.log("status:" + status);
            if (status != "0") {
                layer.msg("图片认证失败，请更换图片")
                return;
            }

            //获取当前选择设备
            $("#yuangong tr").each(function () {
                var obj = new Object();
                console.log($(this));
                obj.devId = $(this).children(":first").attr("id");
                obj.startTime = $(this).children().eq(1).children(":first").val();
                obj.endTime = $(this).children().eq(2).children(":first").val();
                datas.push(obj);
                console.log("devos" + obj)
            });
        } else if (userType == 2) {
            $("#fangke tr").each(function () {
                var obj = new Object();
                console.log($(this));
                obj.devId = $(this).children(":first").attr("id");
                obj.code = $(this).children().eq(1).text();
                obj.visitDate = $(this).children().eq(2).children(":first").val();
                obj.startTime = $(this).children().eq(3).children(":first").val();
                obj.endTime = $(this).children().eq(4).children(":first").val();
                datas.push(obj);
            });
        }
        if (isNull(datas) || datas.length == 0) {
            layer.msg("请添加设备")
            return;
        }
        var data = JSON.stringify({
            "deptId": deptId, "devos": datas, "userType": userType,
            "userName": userName, "userSex": userSex, "mobile": mobile,
            "cardNo": cardNo, "userPhoto": userPhoto, "userNo": userNo
        });
        $.ajax({
            url: "../cuser/addUser",
            type: "post",
            data: data,
            contentType: 'application/json',
            async: false,
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {
                    layer.alert("保存成功", function () {
                        window.location.href = "../cuser/toUserPage";
                    })
                } else {
                    layer.msg(data.msg);
                }
            }
        })
    }

    /**判断是否是手机号**/
    function isPhoneNumber(tel) {
        var reg = /^0?1[3|4|5|6|7|8][0-9]\d{8}$/;
        return reg.test(tel);
    }

    function loadData() {
        var data = {userNo: userNo}
        $.ajax({
            url: "../cuser/getUserById",
            type: "get",
            data: data,
            async: false,
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {
                    if (!isNull(data.data)) {
                        $("#deptName").val(data.data.deptId);
                        $("#gou").val(data.data.userType);
                        $("#userName").val(data.data.userName);
                        $("#userSex").val(data.data.userSex);
                        $("#mobile").val(data.data.mobile);

                        //    判断用户类型
                        if (data.data.userType == 2) {
                            $("#xiaoshi").css("display", "none")
                            $("#xiaoshi2").css("display", "none")
                            $("#contentGou").css("display", "none")
                            $("#contentGou2").css("display", "")
                            if (data.data.devos.length > 0) {
                                var str = "";
                                for (var i = 0; i < data.data.devos.length; i++) {
                                    str += "<tr><td id=" + data.data.devos[i].devId + ">" + data.data.devos[i].devName + "</td><td>" + data.data.devos[i].code + "</td>"
                                    str += "<td><input type=\"text\" value='" + data.data.devos[i].visitDate + "' placeholder=\"请选择\" class=\"form-input-time2 test-ytd test-item2\"></td>" +
                                        "<td><input type=\"text\" value='" + data.data.devos[i].startTime + "' placeholder=\"-\" class=\"form-input-time2 test-start test-item\"></td>" +
                                        "<td><input type=\"text\" value='" + data.data.devos[i].endTime + "' placeholder=\"-\" class=\"form-input-time2 test-end test-item\"></td>" +
                                        "<td><span class=\"blue\" onclick='delDev(this)'>删除</span></td></tr>"
                                }
                                $("#fangke").html(str);
                                $("#qing2").css("display", "none")
                            }
                        } else {
                            $("#cardId").val(data.data.cardNo);
                            if (isNull(data.data.userPhoto)) {
                                $("#showImg").attr("src", '../static/img/moren.png');
                            } else {
                                $("#showImg").attr("src", data.data.userPhoto);
                            }
                            isFaceApiIdentify(data.data.userPhoto);
                            var str = "";
                            for (var i = 0; i < data.data.devos.length; i++) {
                                str += "<tr><td id=" + data.data.devos[i].devId + ">" + data.data.devos[i].devName + "</td>"
                                if (data.data.devos[i].type == 1) {
                                    str += "<td><input type=\"text\" value='" + data.data.devos[i].startTime + "' placeholder=\"-\"  class=\"form-input-time1 test-item\"></td>" +
                                        "<td><input type=\"text\" value='" + data.data.devos[i].endTime + "' placeholder=\"-\"  class=\"form-input-time1 test-item\"></td>" +
                                        "<td><input type=\"checkbox\" name=\"111\" lay-skin=\"primary\"lay-filter='che'></td>" +
                                        "<td><span class=\"blue\" onclick='delDev(this)'>删除</span></td></tr>"
                                } else {
                                    str += "<td><input type=\"text\" placeholder=\"-\" disabled='disabled'  class=\"form-input-time1 test-item\"></td>" +
                                        "<td><input type=\"text\" placeholder=\"-\"  disabled='disabled' class=\"form-input-time1 test-item\"></td>" +
                                        "<td><input type=\"checkbox\" checked=\"checked\" name=\"111\" lay-skin=\"primary\"lay-filter='che'></td>" +
                                        "<td><span class=\"blue\" onclick='delDev(this)'>删除</span></td></tr>"
                                }
                            }

                            $("#yuangong").html(str);
                            $("#qing").css("display", "none")

                        }
                    }
                }
            }
        })
    }

    //验证人脸
    function isFaceApiIdentify(imageUrl) {
        var formDate = {
            imageUrl: imageUrl,
        }
        $.ajax({
            url: "../cuser/isFaceApiIdentify",
            type: "post",
            dataType: "json",
            data: formDate,
            async: true,
            success: function (data) {
                $("#status").html(data.msg);
                $("#status").attr("value", data.code);
                if (data.code == 0) {
                    $("#status").css("color", "green")
                } else if (data.code == 99) {
                    $("#status").css("color", "red")
                } else {
                    $("#status").css("color", "red")
                }
            }
        });
    }
</script>
</body>
</html>
